//package com.jzo2o.trade.config;
//
//import cn.hutool.core.convert.Convert;
//import cn.hutool.core.util.StrUtil;
//import lombok.Data;
//import org.redisson.Redisson;
//import org.redisson.api.RedissonClient;
//import org.redisson.config.Config;
//import org.redisson.config.SingleServerConfig;
//import org.springframework.boot.autoconfigure.data.redis.RedisProperties;
//import org.springframework.boot.context.properties.EnableConfigurationProperties;
//import org.springframework.context.annotation.Bean;
//import org.springframework.context.annotation.Configuration;
//
//import javax.annotation.Resource;
//
//@Configuration
//@EnableConfigurationProperties(RedisProperties.class)
//@Data
//public class RedissonConfiguration {
//
//    @Resource
//    private RedisProperties redisProperties;
//
//    @Bean
//    public RedissonClient redissonSingle() {
//        Config config = new Config();
//        SingleServerConfig serverConfig = config.useSingleServer()
//                .setAddress("redis://" + redisProperties.getHost() + ":" + redisProperties.getPort());
//        if (null != (redisProperties.getTimeout())) {
//            serverConfig.setTimeout(1000 * Convert.toInt(redisProperties.getTimeout().getSeconds()));
//        }
//        if (StrUtil.isNotEmpty(redisProperties.getPassword())) {
//            serverConfig.setPassword(redisProperties.getPassword());
//        }
//        return Redisson.create(config);
//    }
//
//}
